/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// x11scr24.hpp - PegScreen class definition for running as a X11 app.
//
// Copyright (c) 1997-2007 Swell Software 
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software
// is strictly prohibited.
//
// Notes:
//
//    This version of PegScreen is used for the X11 development
//    environment. This version implements a 32bpp color PegScreen
//    under X11. This color depth is used for running PEG WindowBuilder
//    on X. 
//
//    It is important to note that the internal image data is stored
//    as 32bpp (since there is no such thing as a 24bpp bitmap image
//    on X). Therefore, we assume that COLORVAL is defined as a
//    32 bit data type (PEGULONG). 
//
// This class defines all of the methods which must be supported in 
// instantiated screen classes. Users may of course add additional members
// in custom derived classes, but only those members found here will be used
// by PEG.
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#ifndef X11SCR24_HPP_
#define X11SCR24_HPP_

#include "l24scrn.hpp"  //Include the template class
/*--------------------------------------------------------------------------*/
// In the X11 environment, you can configure PEG to maintain
// a fixed virtual screen size (the most common case), or to re-size the
// virtual screen to match the client area of the X11 window client
// area.
//
// Most embedded platforms have a fixed screen size, and true emulation
// is best served by turning off PEG_SIZE_TO_WIN_CLIENT.
/*--------------------------------------------------------------------------*/

#if defined(PEG_MULT_SOFT_SURFACES)
/*--------------------------------------------------------------------------*/
// We also need a forward reference to PegWindow for the method prototypes
/*--------------------------------------------------------------------------*/
class PegWindow;
#endif  // PEG_MULT_SOFT_SURFACES

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
class PegX11Screen : public L24Screen
{
    public:

        PegX11Screen(const PegRect &);
        virtual ~PegX11Screen();

        virtual PEGINT BeginDraw(PegThing *Caller, const PegRect &Invalid,
                PEGINT Surface);
        virtual void EndDraw(void);
        XVisualInfo* GetXVisualInfo(void) const { return mpVisual; }

       #if defined(PEG_SIZE_TO_WIN_CLIENT)
        void SetNewX11WinSize(PEGUINT wWidth, PEGUINT wHeight);
       #endif

       #if defined(PEG_MOUSE_SUPPORT)
        virtual void SetPointer(PegPoint Pos) { mLastPointerPos = Pos; }
        virtual void SetPointerType(PEGUINT Type);
       #endif  // PEG_MOUSE_SUPPORT
        void SetWindowTitle(char *pText);

    protected:
        virtual PEGBOOL AllocateXScreen(PEGUINT wWidth, PEGUINT wHeight);
        virtual PEGBOOL GetPreferredXVisual(PEGUINT iDepth, PEGINT iClass,
                XVisualInfo *pVisualInfo);

       #if defined(PEG_MOUSE_SUPPORT)
        virtual void HidePointer(void) {};
       #endif  // PEG_MOUSE_SUPPORT
        virtual void MemoryToScreen(void);

        char* mpImageMem;        
        PEGCOLOR *mpVidMem;
        PEGCOLOR** mpImageScanPointers;
        XImage* mpXImage;
        XVisualInfo* mpVisual;
        Cursor mtCursor;

       #if defined(PEG_MULT_SOFT_SURFACES)
        PEGUBYTE *mpCompositeBuffer;
       #endif
};

#endif  /* X11SCR24_HPP_ */

